<template>
  <div class="shopInfo" v-if="Object(shopInfo.keys).length !== 0">
    <div class="logo">
      <img :src="shopInfo.logo" alt="" />
      <span>{{ shopInfo.name }}</span>
    </div>
    <div class="shop-middle">
      <div>
        <p class="count">{{ shopInfo.sellCount | countFilter}} </p>
        <p class="desc-title">总销量</p>
      </div>
      <div class="all-goods">
        <p class="count">{{ shopInfo.allGoods }}</p>
        <p class="desc-title">全部宝贝</p>
      </div>
      <div class="score">
        <p v-for="(item, index) in shopInfo.score" :key="index">
          <span>{{ item.name }}</span>
          <span :class="{ red: item.isBetter }">{{ item.score }}</span>
          <span :class="{ isBetter: item.isBetter }" class="better">{{
            item.isBetter ? "高" : "低"
          }}</span>
        </p>
      </div>
    </div>
    <div class="shop-btn">进店逛逛</div>
  </div>
</template>

<script>
export default {
  name: "ShopInfo",
  props: {
    shopInfo: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  filters:{
      countFilter(value){
          let result = value;
          if(value>10000){
              result = (value/10000).toFixed(1)+'万'
          }
          return result;
      }
  }
};
</script>
<style scoped>
.shopInfo {
  border-top: 5px solid #f2f5f8;
  padding: 20px;
}
.logo {
  display: flex;
  align-items: center;
  font-size: 14px;
}
.logo img {
  height: 45px;
  width: 45px;
  border: 1px solid #eee;
  border-radius: 50%;
  margin-right: 10px;
}
.shop-middle {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.all-goods {
  padding-right: 30px;
  border-right: 1px solid #0000001a;
}
.score span {
  margin-right: 10px;
}
.better {
  color: white;
  background: green;
  text-align: center;
  font-size: 12px;
}
.isBetter {
  background: red;
}
.red{
    color: red;
}
.shop-btn{
  width: 150px;
  height: 30px;
  line-height: 30px;
  background: #f6f6f6;
  text-align: center;
  margin: 10px auto;
  font-size: 13px;
  border-radius: 5%;
  letter-spacing: 1px;
}
.count{
    font-size: 16px;
     line-height: 20px;
}
.desc-title{
    font-size: 12px;
    line-height: 20px;
    margin-top: -10px;
}
</style>